﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace ShopOnline.Models.DAL
{
    public class DAL_Advert
    {
         private ShopOnline.Models.ShopOnlineDBDataContext SC_DB;
         public DAL_Advert()
        {
            SC_DB = new ShopOnlineDBDataContext();
        }


        public List<Advert> getListAdvert()
        {
            return SC_DB.Adverts.ToList();
        }

        public List<Advert> getListAdvertIsShow()
        {
            return (from c in SC_DB.Adverts where c.Show == true select c).ToList();
        }

        public Advert getAdvertById(int AdvertId)
        {
            return (from c in SC_DB.Adverts where c.Id == AdvertId select c).FirstOrDefault();
        }

        public List<Advert> getTopnAdvert(int n)
        {
            var list = (from c in SC_DB.Adverts orderby c.Priority ascending, c.Id descending select c).Skip(0).Take(n).ToList();
            return list;
           
        }

    }
}